﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=1">
    <meta name="format-detection" content="telephone=no">
    <meta charset="UTF-8">
    <title>事件修饰符之stop&capture&self实例详解</title>
    <link href="../css/bootstrap.css"/>
    <link href="../css/bootstrap-theme.css"/>

    <style>
        .div{
            border:1px solid red;
            width: 100%;
        }
    </style>
</head>
<body>
    <h1>事件修饰符之stop&capture&self实例详解</h1><br/>

    <div id="app">
        <p>最平常的冒泡模式</p>
        <p>从最底下的事件逐步往上冒,先执行button的事件，再执行div的</p>
        <div @click="b('div')" class="div">
            <button @click="a('button')">button</button>
        </div>
        <br />
        <hr />
        <hr />

        <p>事件修饰符stop</p>
        <p>当你点击在button上的时候，div的事件不会触发，只有点在div上才会触发</p>
        <div @click="b('div')" class="div">
            <button @click.stop="a('button')">button</button>
        </div>
        <br />
        <hr />
        <hr />
        <p>事件修饰符self</p>
        <p>该事件的意思是只有点击div才会触发，从里面的子元素冒泡上来的事件不处理</p>
        <div @click.self="b('div')" class="div">
            <button @click="a('button')">button</button>
        </div>
        <br />
        <hr />
        <hr />
        <p>事件修饰符capture</p>
        <p>该事件的意思是捕获，意思就是从父级的事件开始往下执行</p>
        <div @click.capture="b('div')" class="div">
            <button @click="a('button')">button</button>
        </div>

    </div>
<script src="../js/jquery-2.2.0.min.js"></script>
<script src="../js/vue-2.5.16.js"></script>
<script src="../node_modules/axios/dist/axios.js"></script>
<script src="../node_modules/lodash/lodash.js"></script>

<script>
    var app = new Vue({
        el:'#app',
        methods:{
            a(b){
                alert(b);
            },
            b(b){
                alert(b);
            }
        },
        data:{

        }
    });
</script>

</body>
</html>